﻿<%@page import="language.TextHandler"%>
<%@page import="language.Languages"%>
<%@page import="java.util.HashMap"%>

<jsp:useBean id="c" scope="session" class="nftrainer.Controller"/>
<jsp:useBean id="textHandler" scope="session" class="language.TextHandler"/>
<%
if (request.getParameter("points") != null && !"".equals(request.getParameter("points"))) {
	try {
		int points = Integer.parseInt(request.getParameter("points"));
		c.addPoints(points);
		out.println(textHandler.printf("index.actualpoints")+": "+request.getParameter("points")+"<br />");
		out.println(textHandler.printf("index.points")+": "+c.getPoints()+"<br />");
	} catch (NumberFormatException e) {}
}
out.println("<h3>"+textHandler.printf("index.samplesol")+"</h3>");
out.println(c.getSolutionAsString()+"<br />");
if (c.getActualTaskNumber() > 3) {
	%>
	<div>
	<%
	HashMap<Integer, String[][]>map = c.getSolutionTaskTable();
	int size = map.size();
	for (int n = 0; n < size; n++) {
		out.println("<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"cursor:auto;\" class=\"taskTable\">");
		String[][] table = map.get(n);
		for (int i = 0; i < table.length; i++) {
			if (i == 0) {
				out.println("<thead>");
			} else if (i == 1) {
				out.println("<tbody>");
			}
			out.println("<tr>");
			for (int j = 0; j < table[0].length; j++) {
				out.print((i==0 ? "<th style=\"cursor:auto;\" class=\"taskTable\">" : "<td class=\"taskTable\">")+table[i][j]+((i==0) ? "</th>" :"</td>"));
			}
			out.println("</tr>");
			if (i == 0) {
				out.println("</thead>");
			}
		}
		out.println("</tbody>");
		out.println("</table><br />");
	}
	%>
	</div><div style="clear:both;"></div>
	<%
}

if(c.getActualTaskNumber() >= 5) {
	c.restart();
} else {
	c.next();
}	
%>